package Gui;
import com.cloudgarden.resource.SWTResourceManager;

import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
* Description :update an algorithm
* <p>
*
*@author Danielle
*/
public class Update extends org.eclipse.swt.widgets.Composite {

	{
		//Register as a resource user - SWTResourceManager will
		//handle the obtaining and disposing of resources
		SWTResourceManager.registerResourceUser(this);
	}
	
	private Composite allView;
	private Label updateSucces;
	private Button OK;
	static Shell shell;

	/**
	* Overriding checkSubclass allows this class to extend org.eclipse.swt.widgets.Composite
	*/	
	protected void checkSubclass() {
	}
	
	/**
	* Auto-generated method to display this 
	* org.eclipse.swt.widgets.Composite inside a new Shell.
	*/
	public static void showGUI() {
		Display display = Display.getDefault();
		shell = new Shell(display);
		Update inst = new Update(shell, SWT.NULL);
		Point size = inst.getSize();
		shell.setLayout(new FillLayout());
		shell.layout();
		if(size.x == 0 && size.y == 0) {
			inst.pack();
			shell.pack();
		} else {
			Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
			shell.setSize(shellBounds.width, shellBounds.height);
		}
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}

	public Update(org.eclipse.swt.widgets.Composite parent, int style) {
		super(parent, style);
		initGUI();
	}

	private void initGUI() {
		try {
			FormLayout thisLayout = new FormLayout();
			this.setLayout(thisLayout);
			{
				allView = new Composite(this, SWT.NONE);
				FormLayout allViewLayout = new FormLayout();
				FormData allViewLData = new FormData();
				allViewLData.left =  new FormAttachment(0, 1000, 0);
				allViewLData.top =  new FormAttachment(0, 1000, -5);
				allViewLData.width = 294;
				allViewLData.height = 133;
				allView.setLayoutData(allViewLData);
				allView.setLayout(allViewLayout);
				{
					OK = new Button(allView, SWT.PUSH | SWT.CENTER);
					FormData OKLData = new FormData();
					OKLData.left =  new FormAttachment(0, 1000, 114);
					OKLData.top =  new FormAttachment(0, 1000, 69);
					OKLData.width = 64;
					OKLData.height = 22;
					OK.setLayoutData(OKLData);
					OK.setText("OK");
					OK.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							shell.dispose();
							//TODO add your code for OK.widgetSelected
						}
					});
				}
				{
					updateSucces = new Label(allView, SWT.NONE);
					FormData updateSuccesLData = new FormData();
					updateSuccesLData.width = 166;
					updateSuccesLData.height = 42;
					updateSuccesLData.left =  new FormAttachment(215, 1000, 0);
					updateSuccesLData.right =  new FormAttachment(780, 1000, 0);
					updateSuccesLData.top =  new FormAttachment(206, 1000, 0);
					updateSuccesLData.bottom =  new FormAttachment(522, 1000, 0);
					updateSucces.setLayoutData(updateSuccesLData);
					updateSucces.setText("The Update Succeeded");
					updateSucces.setFont(SWTResourceManager.getFont("Tahoma", 11, 0, false, false));
				}
			}
			this.layout();
			pack();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
